<?php

if (!defined('isIncluded'))
	header('location: index.php');

if(isset($_POST['update']))
{

	foreach($_POST as $key => $value)
	{
		$_SESSION['Winkelwagen'][$key]['Aantal'] = $value;
	}
	unset($_SESSION['Winkelwagen']['update']);
	$array = array();
	foreach($_SESSION['Winkelwagen'] as $key)
	{
		echo  (float)$result = $key['Verkoopprijs'] * $key['Aantal'];
		$array[] = $result;
	}
	foreach($array as $key => $value)
	{
		$_SESSION['Winkelwagen'][$key]['Subtotaal'] = floatval($value);
	}
	header("location: index.php?c=product&p=winkelwagen");
}
if(isset($_POST['bestel']))
{
	echo '<div class="notification_ok">Bestelling is verwerkt.</div>';

	global $db;
	$stmt = $db->query("INSERT INTO nieuwsitem (NieuwsitemID, Datum, Titel, Bericht, AuteurID, OntvangerID) VALUES (NULL, '2012-11-01 00:00:00', 'Bestelling geplaatst', 'door ".$_SESSION["Email"]."', '".$_SESSION["GebruikerID"]."', '".$_SESSION["Aanmaker"]."')");


	$stmt = $db->query("SELECT Aanmaker FROM gebruiker WHERE GebruikerID = ".$_SESSION["Aanmaker"]."");
	$stmt->execute();
	$PDOFetch = $stmt->fetch(PDO::FETCH_ASSOC);

	$stmt = $db->query("INSERT INTO nieuwsitem (NieuwsitemID, Datum, Titel, Bericht, AuteurID, OntvangerID) VALUES (NULL, '2012-11-01 00:00:00', 'Bestelling geplaatst', 'door ".$_SESSION["Email"]."', '".$_SESSION["GebruikerID"]."', '".$PDOFetch['Aanmaker']."')");


}


?>
